<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="live.jipiao.entity.Itinerary"%>
<%@page import="live.common.Format"%>
<%@page import="live.common.GetSequence"%>
<%@page import="live.jipiao.dao.AirItinerary"%>
<%@page import="live.pay.ServiceIds"%>
<%@page import="live.common.PostParam"%>
<%@page import="live.pay.SignUtil"%>
<%@ taglib uri="/WEB-INF/tld/fn.tld" prefix="fn" %>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tld/core.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
Itinerary itinerary = (Itinerary)request.getAttribute("itinerary");
String userId=(String)session.getAttribute("ssoclientagent.user");
String req_trans_tm=Format.getInstance().dateFormatString(new Date(), "yyyyMMddHHmmss");
String req_trans_seq=GetSequence.returnSeqNum();
String subject_desc = AirItinerary.returnItinSubject(itinerary);
Map map = new TreeMap();
map.put("service_id",ServiceIds.PRE_AUTH_RES);
map.put("req_org_cd",PostParam.FLIGHT_NAME);
map.put("req_trans_tm",req_trans_tm);
map.put("req_trans_seq",req_trans_seq);
map.put("order_id",itinerary.getItineraryNo());
map.put("seller_id",PostParam.FLIGHT_NAME);
map.put("sub_order_flag","N");
map.put("sub_order_num","0");
map.put("order_desc",subject_desc);
map.put("tot_trans_amt",((int)(Double.parseDouble(itinerary.getPayTotal().toString())*100))+"");
map.put("buyer_id",userId);
map.put("valid_date","0");
map.put("notify_url",PostParam.ITIN_NOTIFY);
map.put("return_url","");
String sign=SignUtil.sign(map,PostParam.PAYKEY);
map.put("sign",sign);
map.put("sign_type","MD5");
request.getSession().setAttribute("map",map);
%>
<!DOCTYPE html PUBliC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>行程单确认</title>
<base href="<%=basePath %>" />
<link href="orderManager/member/css/login.css" rel="stylesheet" type="text/css" />
<LINK href="orderManager/member/css/header-min.css" rel=stylesheet>
<script type="text/javascript" src="orderManager/css/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="script/zDrag.js"></script>
<script type="text/javascript" src="script/zDialog.js"></script>
</head>
<style>
<!--
.tdl{padding-left: 5px;}
.tablet td{height: 30px; line-height: 30px}
.paybtn{width: 100px; height: 30px;border: solid 1px blue;background-color: blue;color: white; cursor: pointer; margin: 5px;}
.paybtned{width: 100px; height: 30px;border: solid 1px gray;background-color: gray;color: white; cursor: pointer; margin: 5px;}

-->
</style>
<body>


<jsp:include page="/pub_head.jsp"></jsp:include>
	<!-- 中间 -->
<div id="page-container">
<div id="content" style="border: solid 1px #0183BD;">
<div align="center">订单信息</div>
<logic:iterate id="order" name="orders">
<table width="760" class="tablet" align="center" border="0">
	<tr>
		<td width="230" height="31" class="tdl">
		  <label><b>订单号</b>：${order.orderNo }</label>
		</td>
		<td width="190" class="tdl"><label><b>PNR编码</b>：${order.pnrNo}</label>
		  </td>
		<td width="190" class="tdl"><label><b>航班号</b>：${order.flightNo}</label>
		   </td>
	    <td width="150" class="tdl"><label><b>机型</b>：${order.model}</label></td>
	</tr>
	<tr>
		<td width="190" height="31" class="tdl">
		  <label><b>出发城市</b>：${order.scity}</label>
		</td>
		<td width="190" class="tdl"><label><b>出发时间</b>：<bean:write name="order" property="depTime" format="yyyy-MM-dd HH:mm"/></label>
		  </td>
		<td width="190" class="tdl"><label><b>到达城市</b>：${order.ecity}</label>
		   </td>
	    <td width="190" class="tdl"><label><b>到达时间</b>：<bean:write name="order" property="arrTime" format="HH:mm"/></label></td>
	</tr>
	<tr>
		<td width="230" height="31" class="tdl" style="text-align: center;">
		  <label><b>乘客信息</b></label>
		</td>
		<td colspan="3" class="tdl">
			<table width="100%" class="bbmc">
				<tr>
					<td><label><b>姓名</b></label></td>
					<td><label><b>证件类型</b></label></td>
					<td><label><b>证件号码</b></label></td>
				</tr>
			<logic:iterate id="passenger" name="order" property="passengerList">
				<tr>
					<td><label>${passenger.username}</label></td>
					<td><label>
					<c:if test="${passenger.cardType==1}">身份证</c:if>
					<c:if test="${passenger.cardType==2}">护照</c:if>
					<c:if test="${passenger.cardType==3}">军官证</c:if>
					</label></td>
					<td><label>${passenger.card}</label></td>
				</tr>		
			</logic:iterate>
			</table>
		</td>
	</tr>
	<!-- add -->
</table>
</logic:iterate>
	<div align="center">行程单信息【${itinerary.itineraryNo}】</div>
	<table align="center" class="tablet" style="width: 500px" border="0">
         <tr>
           <td colspan="2">邮寄费：<font color="red">10</font>元；每张行程单收取 <font color="red">1</font> 元手续费<label></label> </td>
          </tr>
          <tr>
           <td width="20%" style="text-align: right;">收件人&nbsp;&nbsp;</td>
           <td style="text-align: left;">&nbsp;&nbsp;${itinerary.name }</td>
          </tr>
          <tr>
           <td style="text-align: right;">联系电话&nbsp;&nbsp;</td>
           <td style="text-align: left;">&nbsp;&nbsp;${itinerary.phone }</td>
          </tr>
           <tr>
           <td style="text-align: right;">邮政编码&nbsp;&nbsp;</td>
           <td style="text-align: left;">&nbsp;&nbsp;${itinerary.zip }</td>
          </tr>
          <tr>
           <td style="text-align: right;">详细地址&nbsp;&nbsp;</td>
           <td style="text-align: left;">&nbsp;&nbsp;${itinerary.address }</td>
          </tr>
          <tr>
           <td style="text-align: right;">总金额&nbsp;&nbsp;</td>
           <td style="text-align: left;">&nbsp;&nbsp;共计 <label id="lab" style="font-weight: bolder; color: red; font-size: 18px">
           	<fmt:formatNumber value="${itinerary.payTotal}" pattern="#.#"></fmt:formatNumber>
           </label> 元
           <input name="itinerary" id="itineraryNo" type="hidden" value="${itinerary.itineraryNo}" /></td>
          </tr>          
          <tr>
           <td align="center" colspan="2"><input type="button" class="paybtn" id="btn_pay" onclick="startpay()" value="立即支付" />
           	<input type="hidden" value="1" id="second" />
           </td>
          </tr>
	    </table>
	    <form name="pform" action="<%=PostParam.PAY_API%>" method="post"
			target="_blank">
			<input type="hidden" name="service_id" value="<%=ServiceIds.PRE_AUTH_RES%>" />
			<input type="hidden" name="req_org_cd" value="<%=PostParam.FLIGHT_NAME %>" />
			<input type="hidden" name="req_trans_tm" value="<%=req_trans_tm%>" />
			<input type="hidden" name="req_trans_seq" value="<%=req_trans_seq%>" />
			<input type="hidden" name="order_id" value="${itinerary.itineraryNo}" />
			<input type="hidden" name="seller_id" value="<%=PostParam.FLIGHT_NAME %>" />
			<input type="hidden" name="sub_order_flag" value="N" />
			<input type="hidden" name="sub_order_num" value="0" />
			<input type="hidden" name="order_desc" value="<%=subject_desc %>" />
			<input type="hidden" name="tot_trans_amt" value="<%=map.get("tot_trans_amt")%>" />
			<input type="hidden" name="buyer_id" value="<%=userId %>" />
			<input type="hidden" name="valid_date" value="0" />
			<input type="hidden" name="notify_url" value="<%=PostParam.ITIN_NOTIFY%>" />
			<input type="hidden" name="sign" value="<%=sign%>" />
			<input type="hidden" name="sign_type" value="MD5" />
		</form>
<div class="showDivStyle" id="showDiv"
			style="display: none; text-align: left;">
			<ul>
				<li style="color: black;">
					<h2>
						请在弹出的页面内进行支付。
					</h2>
				</li>
				<li style="color: black;">
					<b>付款成功：</b><a href="/flight/itinApply.do?op=search">查看行程单</a>
				</li>
				<li style="display: none;">
					<b>付款失败：</b>查看支付帮助
					</span>
				</li>
			</ul>
			<div class="btndiv">
			</div>
		</div>

<div id="conver"></div>
<div id="loading" style="display:none; border: solid 10px #247FB6;background-color: #FFFFFF; text-align: center;" align="center">
	<div style="height: 90px; border: text-align: left; font-family: '宋体'; " align="center" >
		<span style="float: left;margin: 10px">
			<img src="/images/bg-sys-icon-info.gif" />
		</span>
	<p>&nbsp;</p>
	<p><label style="font-size: 16px;text-align: left;">请在新打开页面内完成支付</label></p>
	<p>&nbsp;</p>
	<p><label style="font-size: 14px;">付款完成前请不要关闭此窗口</label></p>
	</div>
	<p style="vertical-align: bottom; position: relative; margin-top: 10px;">
    <a href="/flight/itinApply.do?op=search" style="height:40px; padding:5px; text-decoration:none; font-size: 14px;font-weight:'bolder'; border:solid; " id="recon">已完成支付</a>
    <!-- <button style="height:40px; border:solid; margin-left:30px; padding:5px; cursor:pointer; font-weight:bolder; font-size: 14px; background-color: #247FB6; color: white;">已完成支付</button> -->
    </p>
</div>
<script type="text/javascript">
<!--

  	var secs = 9;
	var wait = secs * 1000;  	
	function popDiv(){
	$('#btn_pay').attr('disabled',true);
	var windowWidth = document.documentElement.offsetWidth;
	var windowHeight = document.documentElement.offsetHeight;
	$('#loading').css({
                    background: '#FFF',
                    zIndex: 3000,
                    padding: '10px',
                    width: '300px',
                    height: '140px',
                    margin: '0 auto',
                    opacity: 1,
                    position: 'absolute',
                    top: windowHeight/2-134,
                    left: windowWidth/2-172
                  });
   	  $('#recon').css({ background: 'none',color:'gray'}).text('已完成支付 ('+secs+')').attr('disabled',true);
	    for(i = 1; i <= secs; i++)
         {
            window.setTimeout("upTime(" + i + ")", i * 1000);
         }
         $('#conver').css({
         	height:document.documentElement.scrollHeight,
         	width:document.documentElement.offsetWidth,
         	position: 'absolute',
         	margin:'0',
         	padding:'0',
         	left:'0px',
         	top:'0px',
         	opacity: '0.6',
         	zIndex: 3000,
         	background: '#ccc'
         });
     $('#loading').show();
     }
     
     function upTime(num){
     	if(num<secs)
     	{$('#recon').text('已完成支付 ('+((wait/1000)-num)+')');}
     	else{
     		$('#recon').css({background:'#247FB6',color: 'white',cursor:'pointer'}).attr('disabled',false);
     		$('#recon').text('已完成支付');
     	}
     }
//-->
</script>


<script type="text/javascript" defer="defer"> 
<!--
function startpay(){
var tt=$("#second").val();
if(tt==1){
$.ajax({
  url: "/flight/itinApply.do?op=resquestAndResponse",
  cache: false,
  success: function(data){
   if(parseInt(data)==1){
	popDiv();
	$("#second").val(2);
	$(".paybtn").addClass("paybtned");
	$(".paybtn").attr("disabled",true);
	$(".paybtned").unbind("click");
	document.forms['pform'].submit();
			}
  }
}); 
}
}
//-->
</script>
</div>
	
<iframe id="frmLeft" name="frmLeft" src="/orderManager/left_buy.jsp" width="154" height="650" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes"></iframe>
	
</div>
 
<div id="page-container">
<%@include file="/footer.jsp" %>
</div>

	</body>
	</body>
</html>

